#ifndef MATHTOOLS_RAY3D_H_
#define MATHTOOLS_RAY3D_H_

#include "Vector3D.h"

namespace math_tools
{
	// Representation of a ray in 3D, it is defined by one point and a vector.
	class Ray3D
	{
	public:

		Ray3D();
		Ray3D(const Vector3D & point, const Vector3D & direction);

		virtual ~Ray3D();

		// Returns the closest point on the ray from the given point in space.
		Vector3D closestPoint(const Vector3D &_point);

		// Returns the distance from the given point in space.
		double distanceFrom(const Vector3D & point);

		// Returns the squared distance from the given point in space.
		// Used for optimalization purposes.
		double distanceFromSqr(const Vector3D & point);

		// Getters:
	    inline const Vector3D & getDirection() const
	    {
	        return direction_;
	    }

	    inline const Vector3D & getPoint() const
	    {
	        return point_;
	    }

	    // Setters:
	    inline void setDirection(const Vector3D & direction)
	    {
	        this->direction_ = direction;
	    }

	    inline void setPoint(const Vector3D & point)
	    {
	        this->point_ = point;
	    }

	private:

		Vector3D direction_;
		Vector3D point_;
	};
}

#endif
